package ioperations;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOPeration{
    public void work(BookList bookList){
            System.out.println("归还图书.....");
            System.out.println("请输入你要归还的图书");
            Scanner scanner = new Scanner(System.in);
            String name = scanner.nextLine();
            for (int i = 0; i < bookList.GetUsedSize() ; i++) {
                Book book = bookList.books[i];
                if(book.getName().equals(name)){
                    if(book.GetIsborrowed()==false){
                        System.out.println("该书未被借出");
                        return;
                    }
                    book.setIsborrowed(false);
                    System.out.println("归还成功");
                    return;
                }
            }
            System.out.println("这里没有你要归还的书");
    }
}
